
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[spAccident_GetAccident]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spAccident_GetAccident]
GO

GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Eric Liew
-- Create date: 6/2/2009
-- Description:	Get all Plate
-- =============================================
CREATE PROCEDURE [dbo].[spAccident_GetAccident]
(
	@AccidentID		int
)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

SELECT 
		Accident.AccidentId,
		Accident.AccidentDate,
		Accident.DriverId,
		Accident.TaxiId,
		Accident.Comments,
		Accident.Location,
		Accident.Fault,
		Accident.Damages,
		Accident.Costs,
		Accident.RepairedLocation,
		Driver.FirstName + ' ' + Driver.LastName AS Name,
		Plate.PlateNumber
	FROM Accident
	LEFT JOIN Driver
	ON Driver.DriverId = Accident.DriverId
	LEFT JOIN Taxi
	ON Taxi.TaxiId = Accident.TaxiId
	LEFT JOIN Plate
	ON Taxi.PlateId = Plate.PlateId
	WHERE Accident.AccidentId = @AccidentID

END
GO
